const mixins = require("../../common/mixins/index");
Page({
    data: {
        progressPercent: 0,
        info: {}
    },

    async onLoad(options) {
        this.getInfo()
        await mixins.onJudgeAccountSufficient(this)
    },

    getInfo() {
        this.getOpenerEventChannel().on('detail', info => {
            wx.setNavigationBarTitle({
                title: info.oname
            })
            this.setData({ info })
        })
    },

    async onVote(e) {
        await mixins.onVote(e, this)
        await mixins.onJudgeAccountSufficient(this)
    },

    onTapVoteButton() {
        const { coin, goal_coin } = this.data.info
        if (coin >= goal_coin) {
            wx.showToast({
                title: '谢谢您～已经足够啦',
                icon: 'none'
            })
            return
        }
        mixins.onTapVoteButton(this)
    },

    onPreview(e) {
        mixins.onPreview(e)
    },

    onClipboard(e) {
        const { content } = e.currentTarget.dataset
        wx.setClipboardData({
            data: content
        })
    },

    onShareAppMessage(e) {
        return mixins.onShare(e, undefined, `/pages/login/login`, this)
    },

    onShareTimeline(e) {
        return mixins.onShare(e, undefined, `/pages/login/login`, this)
    }
});
